<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp"%>
<!DOCTYPE html>
<html>
<head>
	<title></title>
	<%@ include file="/WEB-INF/component/commonCSS.jsp"%>
    <!--[if lt IE 9]>
        <script src="lib/js/html5shiv.min.js"></script>
        <script src="lib/js/respond.min.js"></script>
    <![endif]-->
    <style type="text/css">
    .box-body{
    margin-top:-2px;
    }    	
    </style>
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>药品列表</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i><spring:message code="message.lable.first"/></a></li>
            <li class="active"><a href="#">交易</a></li>
            <li class="active"><a href="#">药品列表</a></li>
        </ol>
    </section>
    
    <section class="content">
      <form id="form" method="post" class="form-horizontal">    
        <div class=" box box-success">
            <div class="box-body">
               <div class="input">
                    <div class="textalign1"><spring:message code="message.listForm.tongYongMing"/><spring:message code="message.yanZheng.maoHao"/></div>
                    <div class="boxinput">
                        <input type="text" class="textinput" id="drugName" name="drugName" placeholder="<spring:message code="message.listForm.tongYongMing"/>" />
                    </div>
                    <div class="textalign"><spring:message code="message.listForm.XiangMuMingCheng"/><spring:message code="message.yanZheng.maoHao"/></div>
                    <div class="boxinput">
                        <input type="text" class="textinput" id="projName" name="projName" placeholder="<spring:message code="message.listForm.XiangMuMingCheng"/>" />
                    </div>
                    <div class="textalign"><spring:message code="message.listForm.ShengChanQiYe"/><spring:message code="message.yanZheng.maoHao"/></div>
                    <div class="boxinput">
                        <input type="text" class="textinput" id="compName" name="compName" placeholder="<spring:message code="message.listForm.ShengChanQiYe"/>" />
                    </div>
               </div>
               <div class="moreSerch" style="display:none;">
               <div class="input">
                    <div class="textalign1"><spring:message code="message.listForm.yaoPinBianMa"/><spring:message code="message.yanZheng.maoHao"/></div>
                    <div class="boxinput">
                        <input type="text" class="textinput" id="drugCode" name="drugCode" placeholder="<spring:message code="message.listForm.yaoPinBianMa"/>" />
                    </div>
                    <div class="textalign"><spring:message code="message.listForm.ZhongBiaoQiYe"/><spring:message code="message.yanZheng.maoHao"/></div>
                    <div class="boxinput">
                        <input type="text" class="textinput" id="catCompName" name="catCompName" placeholder="<spring:message code="message.listForm.ZhongBiaoQiYe"/>" />
                    </div>
                    <div class="textalign"><spring:message code="message.listForm.DiJiaYao"/><spring:message code="message.yanZheng.maoHao"/></div>
                    <div class="boxinput">
                        <select class="textinput" id="isLowprice" name="isLowprice">
                            <option value=""><spring:message code="message.select.option"/></option>
                            <option value="0"><spring:message code="message.listForm.fou"/></option>
                            <option value="1"><spring:message code="message.listForm.shi"/></option>
                            <option value="9"><spring:message code="message.listForm.WeiZhi"/></option>
                        </select>
                    </div>
               </div>
               <div class="input">
                    <div class="textalign1"><spring:message code="message.listForm.LianJiaYao"/><spring:message code="message.yanZheng.maoHao"/></div>
                    <div class="boxinput">
                        <select class="textinput" id="isSmallprice" name="isSmallprice">
                            <option value=""><spring:message code="message.select.option"/></option>
                            <option value="0"><spring:message code="message.listForm.fou"/></option>
                            <option value="1"><spring:message code="message.listForm.shi"/></option>
                            <option value="9"><spring:message code="message.listForm.WeiZhi"/></option>
                        </select>
                    </div>
                    <div class="textalign"><spring:message code="message.listForm.GongYingJinZYao"/><spring:message code="message.yanZheng.maoHao"/></div>
                    <div class="boxinput">
                        <select class="textinput" id="isSmallsource" name="isSmallsource">
                            <option value=""><spring:message code="message.select.option"/></option>
                            <option value="0"><spring:message code="message.listForm.fou"/></option>
                            <option value="1"><spring:message code="message.listForm.shi"/></option>
                            <option value="9"><spring:message code="message.listForm.WeiZhi"/></option>
                        </select>
                    </div>
                    <div class="textalign"><spring:message code="message.listForm.YaoPinLaiYuan"/><spring:message code="message.yanZheng.maoHao"/></div>
                    <div class="boxinput">
                        <select class="textinput" id="goodsSource" name="goodsSource">
                            <option value=""><spring:message code="message.select.option"/></option>
                            <option value="1"><spring:message code="message.listForm.ZhaoBiaoCaiGou"/></option>
                            <option value="2"><spring:message code="message.listForm.DingDianShengChan"/></option>
                            <option value="3"><spring:message code="message.listForm.GuaWwangCaiGou"/></option>
                            <option value="4"><spring:message code="message.listForm.YiJiaCaiGou"/></option>
                            <option value="5"><spring:message code="message.listForm.BeiAnCaiGou"/></option>
                        </select>
                    </div>
               </div>
               </div>
               <div class="input" style="margin-left:-150px;">
                    <div class="boxinput" style="width:32%;text-align: center;">
                       <button type="button" onclick="gridSerch()" class="btn btn-success btn-sm" id="selectDicCompType"><spring:message code="message.button.seachSpacing"/></button>
                       <button type="button" onclick="form.reset()" class="btn btn-success btn-sm"><spring:message code="message.button.ChongZhi"/></button>
                       <button type="button" onclick="moreSerch(this)" class="btn btn-success btn-sm"><spring:message code="message.button.GaoJiChaXun"/></button>
                    </div>
               </div>
            </div>
           </div>
        </form> 
        <table class="jqgrid" id="gridlist"></table>
        <div id="prowed2"></div>
</section>
<%@ include file="/WEB-INF/component/commonJS.jsp"%>
<script type="text/javascript">

//绑定回车
$('#drugName,#projName,#compName,#goodsCode,#drugCode,#catCompName,#isLowprice,#isSmallprice,#isSmallsource,#goodsSource,#status').bind('keydown', function(event) {
    if (event.keyCode == "13") {
        $('#selectDicCompType').click();
    }
});	
$("#drugName").focus();//加载页面光标在第一个查询框内



    var searchType = 0;
    
    function moreSerch(obj) {
    	if (searchType == 0) {
    		searchType = 1;
    		$("div.moreSerch").slideDown();
    		$(obj).html("<spring:message code="message.button.JianDanChaXun"/>");
    	} else {
    		searchType = 0;
    		$("div.moreSerch").slideUp();
    		$(obj).html("<spring:message code="message.button.GaoJiChaXun"/>");
    		$("#goodsCode,#drugCode,#catCompName,#isLowprice,#isSmallprice,#isSmallsource").val("");
    	}
    }

		$(function () {
		$("#gridlist").jqGrid({
			url: "${ctx}/baseGoods/getGoodsListByWSJ.html",
		    mtype: "POST",
			datatype: "json",
			autowidth: true,
			shrinkToFit:false,
			// height: create(),
		   	colNames:[
		   	          '<spring:message code="message.jqGrid.cz"/>',
					  '<spring:message code="message.lable.status"/>',
					  '<spring:message code="message.listForm.CaiGouXianJia"/>',
		   	          '<spring:message code="message.listForm.ZuiGaoLingShouJia"/>',
		   	          '<spring:message code="message.listForm.shangBianMa"/>',
		   	       	  '<spring:message code="message.listForm.yaoPinBianMa"/>',
                      '<spring:message code="message.listForm.tongYongMing"/>', 
                      '<spring:message code="message.listForm.jiXing"/>',
                      '<spring:message code="message.listForm.guiGe"/>',
                      '<spring:message code="message.listForm.zhuanHuanXiShu"/>',
                      '<spring:message code="message.listForm.baoZhuangDanWei"/>', 
                      '<spring:message code="message.listForm.caiZhi"/>',
                      '<spring:message code="message.listForm.shengChanQiYe"/>',
                      
                      
                      '国药准字',
		   	          '<spring:message code="message.listForm.ZhongBiaoQiYe"/>',
		   	          '<spring:message code="message.lable.suoShuXiangMu"/>',
		   	          '<spring:message code="message.listForm.YaoPinLaiYuan"/>',
		   	          '<spring:message code="message.listForm.BeiAnLeiXing"/>',
		   	          '<spring:message code="message.listForm.ShangPinFenLei"/>',
		   	          '<spring:message code="message.listForm.shiFouDiJiaYao"/>',
		   	          '<spring:message code="message.listForm.shiFouLianJiaYao"/>',
		   	          '<spring:message code="message.listForm.shiFouGongYinJinZhangYao"/>'
		   	          ],
		   	colModel:[
                {name:'oper',index:'oper',hidden:true, width:40, align:"center",
		            formatter : function(val, opts, rowdata) {
			        var str = "";
			         if (rowdata.status == 1){
			      	str = "<a href=\"javascript:void(0);\" onclick=\"switchStatus('"+rowdata.goodsCode+"','0');\" style='background:url(${ctx}/lib/img/icon/icon.png) no-repeat -40px 0px' class='opIcon' title='<spring:message code="message.listForm.TingYong"/>'></a>";
			         } else if (rowdata.status == 0){
				     str = "<a href=\"javascript:void(0);\" onclick=\"switchStatus('"+rowdata.goodsCode+"','1');\" style='background:url(${ctx}/lib/img/icon/icon.png) no-repeat -60px 0px' class='opIcon' title='<spring:message code="message.listForm.QiYong"/>'></a>";
			         }
			      return str;
	              }	
                },
					{name:'status',index:'statusText', width:60, align:"center",sorttype:false,
		   			formatter : function(val, opts, rowdata) {
                        var str = "";
                        if (val == 0) {
                            str = "<span class='red'><spring:message code="message.listForm.TingYong"/><span>";
                        } else if (val == 1) {
                            str = "<spring:message code="message.listForm.QiYong"/>";
                        }
                        return str;
                    }
		   		},
					{name:'proPriceLimit',index:'proPriceLimit', width:80, align:"right",sorttype:false,
                    	formatter:function(cellvalue, options, row){ 
                    	return formatAmount(cellvalue, options, row);
                    	}},
				{name:'retailPriceLimit',index:'retailPriceLimit', width:80, align:"right",sorttype:false,
				    formatter:function(cellvalue, options, row) {
						var f_x = Math.round(cellvalue * 100) / 100;
						var s_x = f_x.toString();
						var pos_decimal = s_x.indexOf('.');
						
						if (pos_decimal < 0) {
							pos_decimal = s_x.length;
							s_x += '.';
						}
						
						while (s_x.length <= pos_decimal + 2) {
							s_x += '0';
						}
						return s_x;
					}
				},
				{name:'goodsCode',index:'goodsCode', width:100,align:"center", sorttype:false,hidden:true},
				{name:'drugCode',index:'drugCode', width:100, align:"center",sorttype:false,
		  		    formatter:function(val, opts, row) {
		  		     return "<a href=\"javascript:showDrugInfo('"+val+"')\">"+val+"</a>"
		  			}
		  		},
		   		{name:'qualityspecName',index:'drugName', width:140,align:"left", sorttype:false},
		   		{name:'formName',index:'formName', width:80, align:"center"},
		   		{name:'specName',index:'specName', width:80, align:"left",sorttype:false},
		   		{name:'factor',index:'factor', width:80, align:"center",sorttype:false},
		   		{name:'unitName',index:'unit', width:40, align:"center",sorttype:false},
		   		{name:'materialName',index:'materialName', width:80, align:"left",sorttype:false},
		   		{name:'compName',index:'compName', width:180, align:"left",sorttype:false,
		     		 formatter:function(val, opts,row) {
		     			 return "<a href='javascript:showCompInfo(\"" + row.compCode + "\", \"" + val + "\");'>"+val+"</a>"
		     		}
		  		},
		  		
		  		
		  		{name:'drugMedicine',index:'drugMedicine', width:40, align:"center",sorttype:false},
		  		{name:'catCompName',index:'compName', width:180, align:"left",sorttype:false,
                    formatter:function(val, opts,row) {
                        return "<a href='javascript:showCompInfo(\"" + row.catCompCode + "\", \"" + val + "\");'>"+val+"</a>"
                    }
               },
		   		
		   		{name:'projName',index:'projectName', width:200, align:"left",sorttype:false},
				{name:'goodsSource',index:'bakDrugFlagText', width:80, align:"center",sorttype:false,
				   	formatter : function(val, opts, rowdata) {
		   				var str = "";
		   				if (val == 1) {
		   					str = "<spring:message code="message.listForm.ZhaoBiaoCaiGou"/>";
		   				} else if (val == 2) {
		   					str = "<spring:message code="message.listForm.DingDianShengChan"/>";
		   				} else if (val == 3) {
                            str = "<spring:message code="message.listForm.GuaWwangCaiGou"/>";
                        } else if (val == 4) {
                            str = "<spring:message code="message.listForm.YiJiaCaiGou"/>";
                        } else if (val == 5) {
                            str = "<spring:message code="message.listForm.BeiAnCaiGou"/>";
                        }
			   			return str;
					}	
				},
				{name:'isLongtimePlan',index:'isLongTimePlanText', width:80, align:"center",sorttype:false,
					formatter : function(val, opts, rowdata) {
						var str = "";
                        if (val == 0) {
                            str = "<spring:message code="message.listForm.LinShiBeiAn"/>";
                        } else if (val == 1) {
                            str = "<spring:message code="message.listForm.ChangQiBeiAnLeiXing"/>";
                        }
                        return str;
					}
				},
		   		{name:'drugCat',index:'drugCatText', hidden:true, width:100, align:"center",sorttype:false,
					formatter : function(val, opts, rowdata) {
                        var str = "";
                        if (val == 1) {
                            str = "<spring:message code="message.listForm.HuaXueJiShengWuZhiYao"/>";
                        } else if (val == 2) {
                            str = "<spring:message code="message.listForm.ZhongChengYao"/>";
                        } else if (val == 3) {
                            str = "<spring:message code="message.listForm.ZhongYaoYingPian"/>";
                        }
                        return str;
                    }
		   		},
		   		
                {name:'isLowprice', width:80, align:"center",sorttype:false,
                    formatter : function(val, opts, rowdata) {
                        var str = "";
                        if (val == 0) { 
                            str = "<spring:message code="message.listForm.fou"/>";
                        } else if (val == 1) {
                            str = "<spring:message code="message.listForm.shi"/>";
                        } else if (val == 9) {
                            str = "<spring:message code="message.listForm.WeiZhi"/>";
                        }
                        return str;
                    }
                },
                {name:'isSmallprice', width:80, align:"center",sorttype:false,
                    formatter : function(val, opts, rowdata) {
                        var str = "";
                        if (val == 0) {
                            str = "<spring:message code="message.listForm.fou"/>";
                        } else if (val == 1) {
                            str = "<spring:message code="message.listForm.shi"/>";
                        } else if (val == 9) {
                            str = "<spring:message code="message.listForm.WeiZhi"/>";
                        }
                        return str;
                    }
                },
                {name:'isSmallsource', width:90, align:"center",sorttype:false,
                    formatter : function(val, opts, rowdata) {
                        var str = "";
                        if (val == 0) {
                            str = "<spring:message code="message.listForm.fou"/>";
                        } else if (val == 1) {
                            str = "<spring:message code="message.listForm.shi"/>";
                        } else if (val == 9) {
                            str = "<spring:message code="message.listForm.WeiZhi"/>";
                        }
                        return str;
                    }
                }
		   	],
			 rowNum: 20,
		     rowList: [10, 20, 50, 100],
		     rownumbers: true,
		     multiselect: false,
		     pager: "#prowed2",
		     viewrecords: true,
		     gridComplete: function(){
             	//序号列宽度自适应（参数为jqgridID）
                autoRNWidth("gridlist");
             	//数据只有一条时默认选中（参数为jqgridID）
                 selectByOneData("gridlist");
		     },
		     caption: "<spring:message code="message.list.ShangPinMuLuLieBiao"/>",
		     jsonReader: {
		         repeatitems: false,
		         id: "goodsCode"
		     }
		   	
		});
			 
			jQuery("#gridlist").jqGrid('navGrid',"prowed2",{edit:false,add:false,del:false});
			$(window).trigger("resize");
			$("#gridlist").jqGrid("setGridHeight",create());
		});
		
		function gridSerch() {
            var drugName = $.trim($("#drugName").val());
            var projName = $.trim($("#projName").val());
            var compName = $.trim($("#compName").val());
            var goodsCode = $.trim($("#goodsCode").val());
            var drugCode = $.trim($("#drugCode").val());
            var catCompName = $.trim($("#catCompName").val());
            var isLowprice = $.trim($("#isLowprice").val());
            var isSmallprice = $.trim($("#isSmallprice").val());
            var isSmallsource = $.trim($("#isSmallsource").val());
            var goodsSource = $.trim($("#goodsSource").val());
            var status = $.trim($("#status").val());

            $("#gridlist").jqGrid('setGridParam', {  
                datatype:'json',
                postData:{
                    "drugName":drugName,
                    "projName":projName,
                    "compName":compName,
                    "goodsCode":goodsCode,
                    "drugCode":drugCode,
                    "catCompName":catCompName,
                    "isLowprice":isLowprice,
                    "isSmallprice":isSmallprice,
                    "isSmallsource":isSmallsource,
                    "goodsSource":goodsSource,
                    "status":status
                },
                page:1
            }).trigger("reloadGrid"); //重新载入  
        }
		
</script>
</body>
</html>